import json
class Linkedin:

	BLACK_KEY = ('largeLogo','logo','$deletedFields','relevanceReasonInjectionError')
	def  __init__(self,html_dic):
		self.id_dic = {}
		self.entity_dic = {}
		if 'included' not in html_dic or 'data' not in html_dic or 'elements' not in html_dic['data'] or len(html_dic['data']['elements'])<1:
			raise Exception('null entity')
		for dic in html_dic['included']:
			if 'entityUrn' in dic:
				self.entity_dic[dic['entityUrn']] = dic
				del(dic['entityUrn'])
			elif '$id' in dic:
				self.id_dic[dic['$id']] = dic
				del(dic['$id'])
			else:
				print(dic)

		# for element in html_dic['data']['elements']:
		# 	if 'urn:li:fs_normalized_company' in element:
		# 		_type = 'company'
		# 		_id = int(element.split(':')[-1])

		for element in self.entity_dic.values():
			for k,v in element.items():
				if k in self.BLACK_KEY:
					continue
				print(k,':',v)

			print()

			# TODO


class Company():
	pass

if __name__ == '__main__':
	dic = {'data': {'paging': {'links': [], 'count': 10, 'start': 0}, 'elements': ['urn:li:fs_normalized_company:2114']}, 'included': [{'line1': '131 Dartmouth Street', '$type': 'com.linkedin.common.Address', 'city': 'Boston', 'postalCode': '02116', '$deletedFields': ['line4', 'geographicAreaType', 'line3'], '$id': 'urn:li:fs_normalized_company:2114,headquarter', 'country': 'us', 'line2': '', 'geographicArea': 'MA'}, {'$type': 'com.linkedin.common.Date', '$id': 'urn:li:fs_normalized_company:2114,foundedOn', 'year': 1973, '$deletedFields': ['month', 'day']}, {'following': False, 'entityUrn': 'urn:li:fs_followingInfo:urn:li:company:2114', '$type': 'com.linkedin.voyager.common.FollowingInfo', 'followerCount': 433173, '$deletedFields': ['followingCount']}, {'following': False, 'entityUrn': 'urn:li:fs_followingInfo:urn:li:company:10151221', '$type': 'com.linkedin.voyager.common.FollowingInfo', 'followerCount': 8069, '$deletedFields': ['followingCount']}, {'following': False, 'entityUrn': 'urn:li:fs_followingInfo:urn:li:company:11015114', '$type': 'com.linkedin.voyager.common.FollowingInfo', 'followerCount': 935, '$deletedFields': ['followingCount']}, {'entityUrn': 'urn:li:fs_industry:11', '$type': 'com.linkedin.voyager.common.Industry', 'localizedName': 'Management Consulting', '$deletedFields': []}, {'$type': 'com.linkedin.voyager.common.MediaProcessorImage', '$id': 'urn:li:fs_normalized_group:88297,largeLogo,com.linkedin.voyager.common.MediaProcessorImage', 'id': '/p/2/000/014/2ee/0571547.png', '$deletedFields': ['attribution']}, {'$type': 'com.linkedin.voyager.common.MediaProcessorImage', '$id': 'urn:li:fs_normalized_company:2114,coverPhoto,com.linkedin.voyager.common.MediaProcessorImage', 'id': '/p/8/000/219/09e/0c44432.png', '$deletedFields': ['attribution']}, {'$type': 'com.linkedin.voyager.common.MediaProcessorImage', '$id': 'urn:li:fs_normalized_company:2114,logo,image,com.linkedin.voyager.common.MediaProcessorImage', 'id': '/AAEAAQAAAAAAAA0DAAAAJDM5YjM4NDg5LTYzN2MtNDc4MC05Yzk0LWNmZTc5N2U3Mjg1ZQ.png', '$deletedFields': ['attribution']}, {'$type': 'com.linkedin.voyager.common.MediaProcessorImage', '$id': 'urn:li:fs_normalized_group:54058,largeLogo,com.linkedin.voyager.common.MediaProcessorImage', 'id': '/p/3/000/004/2d3/20d68f8.png', '$deletedFields': ['attribution']}, {'$type': 'com.linkedin.voyager.common.MediaProcessorImage', '$id': 'urn:li:fs_normalized_company:2114,overviewPhoto,com.linkedin.voyager.common.MediaProcessorImage', 'id': '/p/8/000/219/09e/0c44432.png', '$deletedFields': ['attribution']}, {'$type': 'com.linkedin.voyager.common.MediaProcessorImage', '$id': 'urn:li:fs_normalized_company:11015114,logo,image,com.linkedin.voyager.common.MediaProcessorImage', 'id': '/AAEAAQAAAAAAAAjZAAAAJGExMGFlZDIyLTNjYzYtNGQxYi1hZTYyLTAyYTc2NzFhMmM4NA.png', '$deletedFields': ['attribution']}, {'$type': 'com.linkedin.voyager.common.MediaProcessorImage', '$id': 'urn:li:fs_normalized_company:2114,backgroundCoverImage,image,com.linkedin.voyager.common.MediaProcessorImage', 'id': '/AAEAAQAAAAAAAAh5AAAAJGVjZWQ3YmFhLTZiMjYtNGU2Ny05ZGJjLWI1ZWZmMWVhNzFlYg.jpg', '$deletedFields': ['attribution']}, {'$type': 'com.linkedin.voyager.common.MediaProcessorImage', '$id': 'urn:li:fs_normalized_company:10151221,logo,image,com.linkedin.voyager.common.MediaProcessorImage', 'id': '/AAEAAQAAAAAAAAXSAAAAJGM1NTFlNmMzLWZmMDAtNGY5Ni05MWZiLWE3M2MwMGE3MWIwMQ.png', '$deletedFields': ['attribution']}, {'entityUrn': 'urn:li:fs_normalized_group:54058', '$type': 'com.linkedin.voyager.groups.Group', 'websiteUrl': 'http://www.bain.com', '$deletedFields': [], 'groupName': 'Bain & Company, Inc.', 'largeLogo': {'com.linkedin.voyager.common.MediaProcessorImage': 'urn:li:fs_normalized_group:54058,largeLogo,com.linkedin.voyager.common.MediaProcessorImage'}, 'url': 'https://www.linkedin.com/groups?gid=54058', 'memberCount': 19829}, {'entityUrn': 'urn:li:fs_normalized_group:88297', '$type': 'com.linkedin.voyager.groups.Group', 'websiteUrl': 'https://alumni.bain.com/', '$deletedFields': [], 'groupName': 'Bain & Company Global Alumni', 'largeLogo': {'com.linkedin.voyager.common.MediaProcessorImage': 'urn:li:fs_normalized_group:88297,largeLogo,com.linkedin.voyager.common.MediaProcessorImage'}, 'url': 'https://www.linkedin.com/groups?gid=88297', 'memberCount': 11049}, {'$id': 'urn:li:fs_normalized_company:2114,backgroundCoverImage', '$deletedFields': ['croppedImage', 'photoFilterEditInfo'], '$type': 'com.linkedin.voyager.identity.profile.BackgroundImage', 'cropInfo': 'urn:li:fs_normalized_company:2114,backgroundCoverImage,cropInfo', 'image': {'com.linkedin.voyager.common.MediaProcessorImage': 'urn:li:fs_normalized_company:2114,backgroundCoverImage,image,com.linkedin.voyager.common.MediaProcessorImage'}}, {'$id': 'urn:li:fs_normalized_company:2114,backgroundCoverImage,cropInfo', 'width': 1400, 'y': 160, '$type': 'com.linkedin.voyager.identity.profile.ImageCropInfo', '$deletedFields': [], 'x': 0, 'height': 204}, {'staffCountRange': 'urn:li:fs_normalized_company:2114,staffCountRange', 'jobSearchPageUrl': 'https://www.linkedin.com/jobs/search?locationId=OTHERS%2Eworldwide&f_C=2114', 'showcase': False, 'type': 'Privately Held', '$deletedFields': ['partnerLogo', 'partnerCompanyUrl', 'rankForTopCompanies', 'acquirerCompany', 'school', 'salesNavigatorCompanyUrl', 'articlePermalinkForTopCompanies', 'autoGenerated'], 'affiliatedCompaniesWithEmployeesRollup': [], 'staffingCompany': False, 'universalName': 'bain-and-company', 'permissions': 'urn:li:fs_normalized_company:2114,permissions', 'followingInfo': 'urn:li:fs_followingInfo:urn:li:company:2114', 'specialities': ['Strategy', 'Customer Strategy & Marketing', 'Performance Improvement', 'Mergers & Acquisitions', 'Private Equity', 'Organization', 'Results Delivery', 'Information Technology', 'Corporate Renewal'], 'claimableByViewer': False, 'entityUrn': 'urn:li:fs_normalized_company:2114', 'overviewPhoto': {'com.linkedin.voyager.common.MediaProcessorImage': 'urn:li:fs_normalized_company:2114,overviewPhoto,com.linkedin.voyager.common.MediaProcessorImage'}, 'companyEmployeesSearchPageUrl': 'https://www.linkedin.com/vsearch/p?f_CC=2114', 'viewerPendingAdministrator': False, 'viewerEmployee': False, 'backgroundCoverImage': 'urn:li:fs_normalized_company:2114,backgroundCoverImage', 'groups': ['urn:li:fs_normalized_group:54058', 'urn:li:fs_normalized_group:88297'], 'dataVersion': 73, 'affiliatedCompaniesWithJobsRollup': [], 'lcpTreatment': False, 'headquarter': 'urn:li:fs_normalized_company:2114,headquarter', 'description': "Bain & Company is one of the world's leading business consulting firms. We work with top executives to help them make better decisions, convert those decisions to actions, and deliver the sustainable success they desire. For forty years, we've been passionate about achieving better results for our clients—results that go beyond financial and are uniquely tailored, pragmatic, holistic, and enduring.\n\nWe advise global leaders on their most critical issues and opportunities: strategy, marketing, organization, operations, technology and mergers & acquisitions, across all industries and geographies.\n\nWe've worked with the majority of the Global 500, thousands of major regional and local companies, and private equity funds representing 75 percent of global equity capital. We are proud of our clients'\u200b track record, like the fact that our public clients have historically outperformed the stock market 4 to 1.\n\nLearn more: http://bain.com/about or http://www.bain.com/careers for careers.\n\nPlease beware of phishing - only apply to jobs via official links. Bain never requests personal financial information in connection with an application.", 'logo': 'urn:li:fs_normalized_company:2114,logo', 'name': 'Bain & Company', 'paidCompany': False, 'affiliatedCompanies': [], 'companyPageUrl': 'http://www.bain.com', 'recentNewsAvailable': True, 'industries': ['Management Consulting'], 'showcasePagesResolutionResults': {'urn:li:fs_normalized_company:10151221': 'urn:li:fs_normalized_company:10151221', 'urn:li:fs_normalized_company:11015114': 'urn:li:fs_normalized_company:11015114'}, 'adsRule': 'STANDARD', '$type': 'com.linkedin.voyager.organization.Company', 'staffCount': 10685, 'groupsResolutionResults': {'urn:li:fs_normalized_group:88297': 'urn:li:fs_normalized_group:88297', 'urn:li:fs_normalized_group:54058': 'urn:li:fs_normalized_group:54058'}, 'foundedOn': 'urn:li:fs_normalized_company:2114,foundedOn', 'claimable': False, 'showcasePages': ['urn:li:fs_normalized_company:10151221', 'urn:li:fs_normalized_company:11015114'], 'viewerConnectedToAdministrator': False, 'url': 'https://www.linkedin.com/company/2114', 'coverPhoto': {'com.linkedin.voyager.common.MediaProcessorImage': 'urn:li:fs_normalized_company:2114,coverPhoto,com.linkedin.voyager.common.MediaProcessorImage'}, 'companyIndustries': ['urn:li:fs_industry:11']}, {'description': "Bain & Company is one of the world's leading management consulting firms. In Germany, you will find our offices in Munich, Frankfurt and Dusseldorf. In Switzerland, our office is located in Zurich.", 'logo': 'urn:li:fs_normalized_company:11015114,logo', 'name': 'Bain Germany & Switzerland', '$type': 'com.linkedin.voyager.organization.Company', 'entityUrn': 'urn:li:fs_normalized_company:11015114', 'industries': ['Management Consulting'], '$deletedFields': [], 'url': 'https://www.linkedin.com/company/11015114', 'followingInfo': 'urn:li:fs_followingInfo:urn:li:company:11015114'}, {'description': 'Digital technology offers companies new ways to deliver on core strategy, delight customers and operate smarter and faster. We help companies turn disruption into opportunity.', 'logo': 'urn:li:fs_normalized_company:10151221,logo', 'name': 'Bain Digital', '$type': 'com.linkedin.voyager.organization.Company', 'entityUrn': 'urn:li:fs_normalized_company:10151221', 'industries': ['Management Consulting'], '$deletedFields': [], 'url': 'https://www.linkedin.com/company/10151221', 'followingInfo': 'urn:li:fs_followingInfo:urn:li:company:10151221'}, {'$id': 'urn:li:fs_normalized_company:11015114,logo', '$deletedFields': [], '$type': 'com.linkedin.voyager.organization.CompanyLogoImage', 'type': 'SQUARE_LOGO', 'image': {'com.linkedin.voyager.common.MediaProcessorImage': 'urn:li:fs_normalized_company:11015114,logo,image,com.linkedin.voyager.common.MediaProcessorImage'}}, {'$id': 'urn:li:fs_normalized_company:10151221,logo', '$deletedFields': [], '$type': 'com.linkedin.voyager.organization.CompanyLogoImage', 'type': 'SQUARE_LOGO', 'image': {'com.linkedin.voyager.common.MediaProcessorImage': 'urn:li:fs_normalized_company:10151221,logo,image,com.linkedin.voyager.common.MediaProcessorImage'}}, {'$id': 'urn:li:fs_normalized_company:2114,logo', '$deletedFields': [], '$type': 'com.linkedin.voyager.organization.CompanyLogoImage', 'type': 'SQUARE_LOGO', 'image': {'com.linkedin.voyager.common.MediaProcessorImage': 'urn:li:fs_normalized_company:2114,logo,image,com.linkedin.voyager.common.MediaProcessorImage'}}, {'$id': 'urn:li:fs_normalized_company:2114,permissions', '$type': 'com.linkedin.voyager.organization.CompanyPermissions', 'adAccountHolder': False, '$deletedFields': [], 'admin': False, 'landingPageAdmin': False}, {'end': 10000, '$id': 'urn:li:fs_normalized_company:2114,staffCountRange', '$type': 'com.linkedin.voyager.organization.shared.StaffCountRange', 'start': 5001, '$deletedFields': []}]}

	# dic = json.loads(js)
	Linkedin(dic)